/****************************************************************************

	COPYRIGHT(C) MAXSI SOFTWARE, JONAS 'SORTIE' TERMANSEN 2008, 2009, 2010

    This file is part of Maxsi Feedback.

    Maxsi Feedback is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Maxsi Feedback is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Maxsi Feedback.  If not, see <http://www.gnu.org/licenses/>.

	*/ #include "MaxsiFeedbackContributors.h" /*

	If you modify this file, please enter your name below and provide contact
	information in MaxsiFeedbackContributors.h. For more information please see
	MaxsiFeedbackContributors.h.
	
	Contributors to this file:

	- Jonas 'Sortie' Termansen
	- [your name here]


	MaxsiFeedback.exe
	An User-Friendly approach to providing developers with instant feedback!

	UI.cpp
	The User Interface for MaxsiFeedback

****************************************************************************/

#include "MaxsiEngine.h"
#include "Main.h" 
#include "UI.h" 
#include "Data.h"

PageFeedback::PageFeedback()
{
}

bool PageFeedback::InitializeForm(ME_Window* Parent)
{
	BaseClass::InitializeForm(Parent);

	HFONT hFont	=	CreateFont (13, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
						OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
						DEFAULT_PITCH | FF_SWISS, "Verdana");

	char*	HeaderSTR	=	BuildString(3,"Hi! Would you like to provide some feedback about ", ProductName,"?");
	char*	LabelSTR	=	BuildString(3,"Developing ", ProductName, " isn't always easy, so you could really help us out if you send us your thoughts on it. Your username will not be posted anywhere. Please spell-check your messages. If you sign the message you might be added as a tester. Thank you!");
	
	Header				=	CreateLabelAEx(WindowHWND,HeaderSTR,0,0,0,0,hFont);
	Label				=	CreateLabelA(WindowHWND,LabelSTR,0,0,0,0);
	Feedback			=	CreateTextExW(WindowHWND,NULL,0,0,0,0,WS_VISIBLE | WS_CHILD | ES_LEFT | WS_VSCROLL | ES_AUTOVSCROLL | ES_MULTILINE);
	Send				=	CreateButtonA(WindowHWND,"Send Feedback!",0,0,0,0);
	NoThanks			=	CreateButtonA(WindowHWND,"No Thanks!",0,0,0,0);
	DontBotherMe		=	CreateCheckButtonA(WindowHWND,"Don't ask me again.",0,0,0,0,false);

	delete[]	HeaderSTR;
	delete[]	LabelSTR;
	

	return	true;
}

bool PageFeedback::RenderForm(HWND hWnd)
{	
	if (!Initialized) { return false; }
    PAINTSTRUCT ps          = {0};
	HDC hDC = BeginPaint (hWnd, &ps);

	RECT rectClient;

    GetClientRect (hWnd, &rectClient);

	DrawSplitLine(hDC,50,rectClient.right);
	
	EndPaint (hWnd, &ps);

	return true;
}

LRESULT PageFeedback::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	return	BaseClass::WindowProc(hWnd,message,wParam,lParam);
}


bool PageFeedback::TerminateForm()
{

	DestroyWindow(Header);
	DestroyWindow(Label);
	DestroyWindow(Send);
	DestroyWindow(NoThanks);
	DestroyWindow(DontBotherMe);

	return	BaseClass::TerminateForm();
}

bool PageFeedback::NewResolution( WORD Width, WORD Height)
{	
	MoveWindow(Header,25,25,Width-25-25,24,TRUE);
	MoveWindow(Label,25,60,Width-25-25,50,TRUE);
	MoveWindow(Feedback,25,110,Width-25-25,Height-110-24-24-12,TRUE);
	MoveWindow(Send,25,Height-24-24,100,24,TRUE);
	MoveWindow(NoThanks,Width-25-100,Height-24-24,100,24,TRUE);
	MoveWindow(DontBotherMe,140,Height-24-24,200,24,TRUE);
	
	RECT r;
	r.bottom=Height;
	r.top=0;
	r.left=0;
	r.right=Width;
	RedrawWindow(WindowHWND,&r,0, RDW_INVALIDATE | RDW_NOINTERNALPAINT | RDW_NOCHILDREN | RDW_ERASE);
	

	return true;
}